{extend name="base"/}
{block name="resources"}
<link rel="stylesheet" href="SHOP_CSS/index.css">
{/block}
{block name="main"}

{if $shop_status == 2}
<div class="ns-shop-state ns-border-color">
	<p class="ns-text-color"><i class="iconfont icongantanhao"></i>店铺剩余{$expire_date}天到期，防止店铺到期影响正常营业，请及时续费。</p>
	<button class="ns-text-color">立即续费</button>
</div>
{/if}

{if $shop_status == -1}
<div class="ns-shop-state ns-border-color">
	<p class="ns-text-color"><i class="iconfont icongantanhao"></i>店铺服务已结束，如需恢复正常营业，请订购店铺套餐。</p>
	<button class="ns-text-color">立即订购</button>
</div>
{/if}
<div class="ns-survey">
	<div class="ns-survey-left">

		<div class="admin-row">
			<div class="admin-col-md2">
				<div class="ns-survey-detail-con">
					<div class="ns-survey-shop">
						<div class="ns-item-pic">
							<img layer-src src="{:img($avatar)}" onerror=src="SHOP_IMG/default_shop.png" />
						</div>
						<div class="ns-surver-shop-detail">
							<p class="ns-survey-shop-name">{$shop_info.site_name}
								{if empty($base_weapp_config) || ( isset($base_weapp_config['is_authopen']) && empty($base_weapp_config['component_appid']) ) || ( !isset($base_weapp_config['is_authopen']) && empty($base_weapp_config['appid']) )}
								<span onclick="releaseNow()">未绑定</span>
								{else/}
								<span class="ns-border-color ns-text-color">已绑定</span>
								{/if}
							</p>
							{if condition="$shop_info['group_name'] eq ''"}
							<p>店铺套餐：<span class="ns-text-color-dark-gray">系统管理</span></p>
							{else/}
							<p>店铺套餐：<span class="ns-text-color-dark-gray">{$shop_info.group_name}</span></p>
							{/if}
							<p>剩余短信：<a href="{:addon_url('shop/message/smsrecords')}">{$shop_info.sms_num}条</a></p>
							<p>到期时间：<span class="ns-text-color-dark-gray">{if condition="$shop_info['expire_time'] eq 0"}永久{else/}{:time_to_date($shop_info['expire_time'])}{/if}</span></p>

						</div>
					</div>
				</div>
			</div>
			<a href="{:addon_url('shop/order/lists',['order_status' => 0])}">
				<div class="admin-col-md1">
					<div class="ns-survey-detail-con">
						<div class="statistics-box">
							<div class="statistics-title">待付款</div>
							<div class="statistics-value">{$num_data.waitpay}</div>
						</div>
					</div>
				</div>
			</a>
			<a href="{:addon_url('shop/delivery/lists')}">
				<div class="admin-col-md1">
					<div class="ns-survey-detail-con">
						<div class="statistics-box">
							<div class="statistics-title">待发货</div>
							<div class="statistics-value">{$num_data['waitsend']}</div>
						</div>
					</div>
				</div>
			</a>
			<a href="{:addon_url('shop/orderrefund/lists')}">
			<div class="admin-col-md1">
				<div class="ns-survey-detail-con">
					<div class="statistics-box">
						<div class="statistics-title">退款中</div>
						<div class="statistics-value">{$num_data['refund']}</div>
					</div>
				</div>
			</div>
			</a>
			<a href="{:addon_url('shop/goods/lists')}">
				<div class="admin-col-md1">
					<div class="ns-survey-detail-con">
						<div class="statistics-box">
							<div class="statistics-title">库存预警</div>
							<div class="statistics-value">{$num_data['goods_stock_alarm']}</div>
						</div>
					</div>
				</div>
			</a>
			{if $is_fenxiao == 1}
			<a href="{:addon_url('fenxiao://shop/fenxiao/apply')}">
				<div class="admin-col-md1">
					<div class="ns-survey-detail-con">
						<div class="statistics-box">
							<div class="statistics-title">分销商申请</div>
							<div class="statistics-value">{$num_data.apply_count}</div>
						</div>
					</div>
				</div>
			</a>
			<a href="{:addon_url('fenxiao://shop/withdraw/lists')}">
				<div class="admin-col-md1">
					<div class="ns-survey-detail-con">
						<div class="statistics-box">
							<div class="statistics-title">提现待审核</div>
							<div class="statistics-value">{$num_data['withdraw_count']}</div>
						</div>
					</div>
				</div>
			</a>
			{/if}
		</div>

		<div class="admin-row">
			<div class="admin-col-md2">
				<div class="ns-survey-detail-con">
					<div class="overview-box">
						<div class="overview-title">
							<div class="overview-title-text">今日订单数</div>

							<div class="title ns-prompt-block overview-prompt">
								<div class="ns-prompt">
									<button class="layui-btn layui-btn-primary ns-text-color ns-border-color ns-survey-yesterday-btn">昨日</button>
									<div class="ns-prompt-box">
										<div class="ns-prompt-con">
											昨日订单数：{if isset($stat_yesterday.order_pay_count)}{$stat_yesterday.order_pay_count}{else /} 0 {/if}
										</div>
									</div>
								</div>
							</div>
							<div class="clear"></div>
						</div>

						<div class="overview-value">{$stat_day.order_pay_count}</div>
						<div class="overview-rate">
							<div>日同比 {$day_rate.order_pay_count}

								{if $day_rate.order_pay_count > 0}
								<img src="SHOP_IMG/shop-rate-add.png">
								{else /}
								<img src="SHOP_IMG/shop-rate-less.png">
								{/if}
							</div>
							<div>周同比 {$week_rate['order_pay_count']}
								{if $week_rate.order_pay_count > 0}
								<img src="SHOP_IMG/shop-rate-add.png">
								{else /}
								<img src="SHOP_IMG/shop-rate-less.png">
								{/if}
							</div>
						</div>

						<div class="overview-bottom">
							<div class="overview-bottom-text">订单总数</div>
							<div class="overview-bottom-value">{$shop_stat_sum.order_pay_count}</div>
							<div class="clear"></div>
						</div>
					</div>

				</div>
			</div>

			<div class="admin-col-md2">
				<div class="ns-survey-detail-con">
					<div class="overview-box">
						<div class="overview-title">
							<div class="overview-title-text">今日销售额</div>

							<div class="title ns-prompt-block overview-prompt">
								<div class="ns-prompt">
									<button class="layui-btn layui-btn-primary ns-text-color ns-border-color ns-survey-yesterday-btn">昨日</button>
									<div class="ns-prompt-box">
										<div class="ns-prompt-con">
											昨日销售额：{if isset($stat_yesterday.order_total)}{$stat_yesterday.order_total}{else /} 0.00 {/if}
										</div>
									</div>
								</div>
							</div>
							<div class="clear"></div>
						</div>

						<div class="overview-value">{if isset($stat_day.order_total)}{$stat_day.order_total}{else /} 0.00 {/if}</div>
						<div class="overview-rate">
							<div>日同比 {$day_rate.order_total}

								{if $day_rate.order_total > 0}
								<img src="SHOP_IMG/shop-rate-add.png">
								{else /}
								<img src="SHOP_IMG/shop-rate-less.png">
								{/if}
							</div>
							<div>周同比 {$week_rate['order_total']}
								{if $week_rate.order_total > 0}
								<img src="SHOP_IMG/shop-rate-add.png">
								{else /}
								<img src="SHOP_IMG/shop-rate-less.png">
								{/if}
							</div>
						</div>

						<div class="overview-bottom">
							<div class="overview-bottom-text">销售总额</div>
							<div class="overview-bottom-value">{$shop_stat_sum.order_total}</div>
							<div class="clear"></div>
						</div>
					</div>


				</div>
			</div>

			<div class="admin-col-md2">
				<div class="ns-survey-detail-con">
					<div class="overview-box">
						<div class="overview-title">
							<div class="overview-title-text">新增会员数</div>

							<div class="title ns-prompt-block overview-prompt">
								<div class="ns-prompt">
									<button class="layui-btn layui-btn-primary ns-text-color ns-border-color ns-survey-yesterday-btn">昨日</button>
									<div class="ns-prompt-box">
										<div class="ns-prompt-con">
											昨日新增会员：{if isset($stat_yesterday.member_count)}{$stat_yesterday.member_count}{else /} 0 {/if}
										</div>
									</div>
								</div>
							</div>
							<div class="clear"></div>
						</div>

						<div class="overview-value">{$stat_day.member_count}</div>
						<div class="overview-rate">
							<div>日同比 {$day_rate.member_count}
								{if $day_rate.member_count > 0}
								<img src="SHOP_IMG/shop-rate-add.png">
								{else /}
								<img src="SHOP_IMG/shop-rate-less.png">
								{/if}
							</div>
							<div>周同比
								{$week_rate['member_count']}
								{if $week_rate.member_count > 0}
								<img src="SHOP_IMG/shop-rate-add.png">
								{else /}
								<img src="SHOP_IMG/shop-rate-less.png">
								{/if}
							</div>
						</div>

						<div class="overview-bottom">
							<div class="overview-bottom-text">会员总数</div>
							<div class="overview-bottom-value">{$member_count}</div>
							<div class="clear"></div>
						</div>
					</div>


				</div>
			</div>

			<div class="admin-col-md2">
				<div class="ns-survey-detail-con">
					<div class="overview-box">
						<div class="overview-title">
							<div class="overview-title-text">今日浏览量</div>

							<div class="title ns-prompt-block overview-prompt">
								<div class="ns-prompt">
									<button class="layui-btn layui-btn-primary ns-text-color ns-border-color ns-survey-yesterday-btn">昨日</button>
									<div class="ns-prompt-box">
										<div class="ns-prompt-con">
											昨日浏览量：{if isset($stat_yesterday.visit_count)}{$stat_yesterday.visit_count}{else /} 0 {/if}
										</div>
									</div>
								</div>
							</div>
							<div class="clear"></div>
						</div>

						<div class="overview-value">{$stat_day.visit_count}</div>
						<div class="overview-rate">
							<div>日同比 {$day_rate.visit_count}
								{if $day_rate.visit_count > 0}
									<img src="SHOP_IMG/shop-rate-add.png">
								{else /}
									<img src="SHOP_IMG/shop-rate-less.png">
								{/if}
							</div>
							<div>周同比
								{$week_rate['visit_count']}
								{if $week_rate.visit_count > 0}
								<img src="SHOP_IMG/shop-rate-add.png">
								{else /}
								<img src="SHOP_IMG/shop-rate-less.png">
								{/if}
							</div>
						</div>

						<div class="overview-bottom">
							<div class="overview-bottom-text">总浏览量</div>
							<div class="overview-bottom-value">{$shop_stat_sum.visit_count}</div>
							<div class="clear"></div>
						</div>
					</div>
				</div>
			</div>

		</div>

		<div class="admin-row">
			<div class="admin-col-md4">
				<div class="ns-survey-detail-con echarts-wrap">
					<div class="echarts-order">
						<h5>近十天订单数(个)</h5>
						<div id="order" style="width: 100%; height: 400px;"></div>
					</div>
				</div>
			</div>
			<div class="admin-col-md4">
				<div class="ns-survey-detail-con echarts-wrap">
					<div class="echarts-money">
						<h5>销售额(元)</h5>
						<div id="money" style="width: 100%; height: 400px;"></div>
					</div>
				</div>
			</div>

		</div>

		<div class="admin-title">常用功能</div>
		<div class="admin-row">
			<div class="admin-col-md1">
				<div class="ns-survey-detail-con">
					<a class="common-functions-item" href="{:url('shop/goods/addgoods')}">
						<div class="common-functions-box">
							<div class="ns-item-pic">
								<img src="SHOP_IMG/menu_icon/issue_good.png">
							</div>
							<div class="ns-item-con">
								<div class="ns-item-content-title">发布商品</div>
								<p class="ns-item-content-desc">发布实物商品</p>
							</div>
						</div>
					</a>
				</div>
			</div>
			<div class="admin-col-md1">
				<div class="ns-survey-detail-con">
					<a class="common-functions-item" href="{:url('shop/diy/index')}">
						<div class="common-functions-box">
							<div class="ns-item-pic">
								<img src="SHOP_IMG/menu_icon/page_decoration.png">
							</div>
							<div class="ns-item-con">
								<div class="ns-item-content-title">店铺装修</div>
								<p class="ns-item-content-desc">主页面进行装修</p>
							</div>
						</div>
					</a>
				</div>
			</div>
			<div class="admin-col-md1">
				<div class="ns-survey-detail-con">
					<a class="common-functions-item" href="{:url('shop/shop/config')}">
						<div class="common-functions-box">
							<div class="ns-item-pic">
								<img src="SHOP_IMG/menu_icon/shop_settings.png">
							</div>
							<div class="ns-item-con">
								<div class="ns-item-content-title">店铺设置</div>
								<p class="ns-item-content-desc">修改店铺信息</p>
							</div>
						</div>
					</a>
				</div>
			</div>
			<div class="admin-col-md1">
				<div class="ns-survey-detail-con">
					<a class="common-functions-item" href="{:url('shop/order/lists')}">
						<div class="common-functions-box">
							<div class="ns-item-pic">
								<img src="SHOP_IMG/menu_icon/order_select.png">
							</div>
							<div class="ns-item-con">
								<div class="ns-item-content-title">订单查询</div>
								<p class="ns-item-content-desc">查询系统普通订单</p>
							</div>
						</div>
					</a>
				</div>
			</div>
			<div class="admin-col-md1">
				<div class="ns-survey-detail-con">
					<a class="common-functions-item" href="{:url('shop/member/index')}">
						<div class="common-functions-box">
							<div class="ns-item-pic">
								<img src="SHOP_IMG/menu_icon/member_manage.png">
							</div>
							<div class="ns-item-con">
								<div class="ns-item-content-title">会员管理</div>
								<p class="ns-item-content-desc">店铺会员管理</p>
							</div>
						</div>
					</a>
				</div>
			</div>
			<div class="admin-col-md1">
				<div class="ns-survey-detail-con">
					<a class="common-functions-item" href="{:url('shop/memberwithdraw/lists')}">
						<div class="common-functions-box">
							<div class="ns-item-pic">
								<img src="SHOP_IMG/menu_icon/member_withdraw.png">
							</div>
							<div class="ns-item-con">
								<div class="ns-item-content-title">会员提现</div>
								<p class="ns-item-content-desc">店铺会员提现</p>
							</div>
						</div>
					</a>
				</div>
			</div>
			{if $is_fenxiao == 1}
			<div class="admin-col-md1">
				<div class="ns-survey-detail-con">
					<a class="common-functions-item" href="{:addon_url('fenxiao://shop/order/lists')}">
						<div class="common-functions-box">
							<div class="ns-item-pic">
								<img src="SHOP_IMG/menu_icon/fenxiao_order.png">
							</div>
							<div class="ns-item-con">
								<div class="ns-item-content-title">分销订单</div>
								<p class="ns-item-content-desc">店铺分销订单</p>
							</div>
						</div>
					</a>
				</div>
			</div>
			<div class="admin-col-md1">
				<div class="ns-survey-detail-con">
					<a class="common-functions-item" href="{:addon_url('fenxiao://shop/fenxiao/index')}">
						<div class="common-functions-box">
							<div class="ns-item-pic">
								<img src="SHOP_IMG/menu_icon/fenxiao_config.png">
							</div>
							<div class="ns-item-con">
								<div class="ns-item-content-title">分销管理</div>
								<p class="ns-item-content-desc">店铺分销管理</p>
							</div>
						</div>
					</a>
				</div>
			</div>
			{/if}
		</div>


		<div class="admin-row">
			<div class="admin-col-md4">
				<div class="admin-title">营销活动<div class="more"><a class="ns-text-color" href="{:addon_url('shop/promotion/index')}">更多</a></div></div>
			</div>
			<div class="admin-col-md4">
				<div class="admin-title">应用工具<div class="more"><a class="ns-text-color" href="{:addon_url('shop/promotion/tool')}">更多</a></div></div>
			</div>
		</div>

		<div class="admin-row">
			<div class="admin-col-md4">
				<div class="ns-survey-detail-con">
					<div class="ns-item-block-parent">
						{php} $num = 0; {/php}
						{foreach $promotion as $list_k => $list_v}
						{empty name="$list_v['is_developing']"}
						{if in_array($list_v['show_type'],['shop','member']) && $num <5}
						{php} $num++;{/php}
						<a class="ns-item-block ns-item-block-hover-a" {empty name="$list_v['is_developing']"} href="{:addon_url($list_v['url'])}" {/empty}>
						<div class="ns-item-block-wrap">
							<div class="ns-item-pic">
								<img src="{:img($list_v.icon)}">
							</div>
							<div class="ns-item-con">
								<div class="ns-item-content-title">{$list_v.title}</div>
								<p class="ns-item-content-desc ns-line-hiding" title="{$list_v.description}">{$list_v.description}</p>
							</div>
						</div>
						</a>
						{/if}
						{/empty}
						{/foreach}
					</div>
				</div>
			</div>

			<div class="admin-col-md4">
				<div class="ns-survey-detail-con">
					<div class="ns-item-block-parent">
						{php} $tool_num = 0; {/php}
						{foreach $promotion as $list_k => $list_v}
						{empty name="$list_v['is_developing']"}

						{if $list_v['show_type'] == 'tool' && $tool_num < 5}
						{php} $tool_num++; {/php}
						<a class="ns-item-block ns-item-block-hover-a" {empty name="$list_v['is_developing']"} href="{:addon_url($list_v['url'])}" {/empty}>
						<div class="ns-item-block-wrap">
							<div class="ns-item-pic">
								<img src="{:img($list_v.icon)}">
							</div>
							<div class="ns-item-con">
								<div class="ns-item-content-title">{$list_v.title}</div>
								<p class="ns-item-content-desc ns-line-hiding" title="{$list_v.description}">{$list_v.description}</p>
							</div>
						</div>
						</a>
						{/if}

						{/empty}
						{/foreach}
					</div>
				</div>
			</div>
		</div>
	</div>


	<div class="ns-survey-right">
		<div class="shop-index-btn layui-btn" onclick="getShopUrl()">访问店铺</div>
		<div class="shop-kefu-box">
			<img src="SHOP_IMG/shop-kefu.png">
			<div class="shop-kefu">
				<div class="shop-kefu-text">联系客服</div>
				<div class="shop-kefu-phone">电话：{$website_info['web_phone']}</div>
			</div>
			<div class="clear"></div>
		</div>

		<!-- 网站公告 -->
		<div class="layui-card ns-survey-help">
			<div class="layui-card-header"><span><img src="SHOP_IMG/shop-notice.png"/>网站公告</span><a class="ns-text-color" href="{:url('shop/notice/index')}">更多</a></div>
			<div class="layui-card-body">
				{foreach $notice_list as $list_k => $list_v}
				<a class="layui-elip" href="{:url('shop/notice/detail')}?id={$list_v.id}">
					<span class="type"></span><span>{$list_v.title}</span>
				</a>
				{/foreach}
			</div>
		</div>

		<!-- 入驻帮助 -->
		<div class="layui-card ns-survey-help">
			<div class="layui-card-header"><span><img src="SHOP_IMG/shop-help.png"/>网站帮助</span><a class="ns-text-color" href="{:url('shop/shophelp/helplist')}">更多</a></div>
			<div class="layui-card-body">
				{foreach $help_list as $list_k => $list_v}
				<a class="layui-elip" href="{:url('shop/shophelp/helpDetail')}?help_id={$list_v.id}">
					<span class="type">[{$list_v.class_name}]</span><span>{$list_v.title}</span>
				</a>
				{/foreach}
			</div>
		</div>

	</div>
</div>
{/block}
{block name="script"}
<script src="SHOP_JS/echarts.min.js"></script>
<script>
    $(function () {
        $("body").on("click", ".ns-shop-state button", function () {
            location.href = ns.url("shop/index/renewExpireTime");
        });

        var ten_day_json = {:json_encode($ten_day, JSON_UNESCAPED_UNICODE)} ;
        function getDay(day){
            var today = new Date();
            var targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day;
            today.setTime(targetday_milliseconds); //注意，这行是关键代码
            var tYear = today.getFullYear();
            var tMonth = today.getMonth();
            var tDate = today.getDate();
            tMonth = doHandleMonth(tMonth + 1);
            tDate = doHandleMonth(tDate);
            return tMonth + "-" + tDate;
        }

        function doHandleMonth(month){
            var m = month;
            if(month.toString().length == 1){
                m = "0" + month;
            }
            return m;
        }

        var data = [getDay(-9), getDay(-8), getDay(-7), getDay(-6), getDay(-5), getDay(-4), getDay(-3), getDay(-2), getDay(-1), getDay(0)];
        var myChart = echarts.init(document.getElementById('order'));

        // 指定图表的配置项和数据
        option = {
            xAxis: {
                type: 'category',
                data: data
            },
            yAxis: {
                type: 'value'
            },
            tooltip: {
                formatter: function(params, ticket, callback) {
                    return "日期：" + data[params.dataIndex] + '<br />' + params.seriesName + "：" + params.value;
                },
                backgroundColor: 'rgba(0, 0, 0, 0.5)',
                padding: [5, 10],
                textStyle: {
                    color: '#fff',
                    lineHeight: 30,
                }
            },
            series: [{
                name: ['订单数'],
                data: ten_day_json.order_pay_count,
                type: 'bar',
                showBackground: true,
                barCategoryGap: '50%',
                itemStyle: {
                    color: new echarts.graphic.LinearGradient(
                        0, 0, 0, 1,
                        [
                            {offset: 0, color: '#e38c62'},
                            {offset: 1, color: '#ff8143'}
                        ]
                    )
                }
            }]
        };

        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);

        // 基于准备好的dom，初始化echarts实例
        var moneyChart = echarts.init(document.getElementById('money'));

        // 指定图表的配置项和数据
        moneyOption = {
            xAxis: {
                type: 'category',
                data: data
            },
            yAxis: {
                type: 'value'
            },
            tooltip: {
                trigger: 'axis',
                showContent: true,
                backgroundColor: 'rgba(0, 0, 0, 0.5)',
                padding: [5, 10],
                textStyle: {
                    color: '#fff',
                    lineHeight: 30,
                },
                formatter: function(params, ticket, callback) {
                    return "日期：" + params[0].axisValue + '<br />' + params[0].seriesName + "：" + params[0].value + "元";
                },
            },
            series: [{
                name: ['销售额'],
                data: ten_day_json.order_total,
                type: 'line',
                smooth: true,
                itemStyle: {
                    color: '#FF8143'
                }
            }]
        };

        // 使用刚指定的配置项和数据显示图表。
        moneyChart.setOption(moneyOption);
    });
</script>
{/block}
{/block}